from selenium import webdriver
import time

# 初始化浏览器驱动
driver = webdriver.Chrome()
# 先访问淘宝首页（必须先访问，否则添加Cookie会报域名错误）
driver.get("https://www.taobao.com")

# 添加手动获取的Cookie（需替换为实际的name和value）
cookies = [
    {"name": "_m_h5_tk", "value": "90f0d042891320fd6837b9556a6ce846_1761911773175"},
    {"name": "_m_h5_tk_enc", "value": "4f38799b93bd04a62c5805ac669b03b4"},
    {"name": "cookie2", "value": "120c258a053d2d5816849ba9128200e9"},
    {"name": "cna", "value": "Id/iICQDhRkCAXkf4mrOYpX2"},
    {"name": "uc1", "value": "pas=0&existShop=false&cookie14=UoYY4vIPy13VDA%3D%3D&cookie16=URm48syIJ1yk0MX2J7mAAEhTuw%3D%3D&cookie21=URm48syIYn73&cookie15=V32FPkk%2Fw0dUvg%3D%3D"},
    {"name": "lgc", "value": "tb533749871"},
    {"name": "tracknick", "value": "tb533749871"},
    {"name": "isg", "value": "BBcXNRhoMmo0ere5qChxfXKrpothXOu-Pk40omlEPOZNmDfacSnoDtKw_jiGRMM2"},
]

for cookie in cookies:
    driver.add_cookie(cookie)

# 刷新页面，使Cookie生效
driver.refresh()
time.sleep(5)  # 等待页面加载

# 进入个人中心（淘宝个人中心地址）
driver.get("https://cart.taobao.com/")
time.sleep(5)


# 关闭浏览器
driver.quit()